package com.onesports.intelligent.k12.polarlight.util;

import java.util.Random;

/**
 * @atuhor wusy
 */
public  class NoUtil {

    /**
     * 生成规则编号:时间+三位编号（从1开始，不够前补0）
     *
     * @param date
     * 				审批类型
     * @param equipmentNo
     * 				最新编号
     * @return 审批编号
     */
    public static String getNewNo(String date, String equipmentNo){
        String newEquipmentNo = date + "001";
        if(equipmentNo != null && !equipmentNo.isEmpty()){
            int no = Integer.parseInt(equipmentNo);
            int newEquipment = ++no;
            newEquipmentNo = String.format(date + "%03d", newEquipment);
        }
        return newEquipmentNo;
    }


    /**
     * function: 生成一个随机的5位流水码（纯数字）
     *
     * @return code 5位流水码
     * @author WangCX
     * @since 2022/7/11 15:45
     */
    public static String code() {
        String s = "0123456789";
        Random sc = new Random();
        StringBuilder code = new StringBuilder(" ");
        for (int i = 0; i < 5; i++) {
            int ax = sc.nextInt(s.length());
            char c = s.charAt(ax);
            code.append(c);
        }
        return code.toString();

    }
}
